<meta charset="utf-8" />
<button onclick="dijian()">-</button>
<input id="num" style="width:40px;" value="0" />
<button onclick="dizeng()">+</button>
<script>
        function dizeng(){
              num.value=parseInt(num.value)+1;
              if(num.value>10){
                  num.value=10;
                  alert("库存只有10件");
              }
        }
        function dijian(){
              num.value=parseInt(num.value)-1;
              if(num.value<0){
                 num.value=0;
              } 
        }
</script>